<template>
  <div style="padding:20px;" id="app">
    <div class="panel panel-primary">
      <div class="align-center">
  <el-table
    :data="tableData"
    border
    style="width: 100%">
    <el-table-column
      prop="username"
      label="申请人">
    </el-table-column>
    <el-table-column
      prop="approveusername"
      label="审批人">
    </el-table-column>
      <el-table-column
        prop="approvestatus"
        label="审批状态"
      :formatter="statusformat">
      </el-table-column>
    <el-table-column
      prop="applyTime"
      label="申请时间">
    </el-table-column>
      <el-table-column
        prop="resourceid"
        label="资源id">
      </el-table-column>
    <el-table-column
      fixed="right"
      label="操作"
      width="100">
      <template slot-scope="scope">
        <el-button @click="accessExcute(scope.row)" type="text" size="small">执行接入</el-button>
      </template>
    </el-table-column>
  </el-table>
</div>
  </div>
  </div>
</template>

<script>
    export default {
      data() {
        return {
          tableData: [{
            dname: '2016-05-02',
            dtype: '王小虎',
            dadress: '上海市普陀区金沙江路 1518 弄'
          }]
        }
      },
      methods: {
        statusformat(row,column){
          let approvestatus = row.approvestatus
          if(approvestatus == 0){
            return "未审批"
          }else if(approvestatus == 1){
            return "已通过"
          }else if(approvestatus == 1){
            return "已退回"
          }
          return "异常"
        },
        accessExcute(row){
          let id = row.id
          this.$http.post('http://127.0.0.1:8091/dataAccessinfo/importdata',
            {id:id
            }
            ,{emulateJSON: true}).then((response) => {
              debugger
              let re = response.body

            if(re.flag == "success"){

            }else if (re.flag == "fail"){

            }
            alert(re.message);
          });
        }
       },
      created() {
        this.$http.post('http://127.0.0.1:8091/resouceApply/listMyResouceApply',
          {
          }
          ,{emulateJSON: true}).then((response) => {
            debugger
          // if(response.bodyText = "success"){
          let data = response.body
          this.tableData = data.resouceapplyinfoList
        });
      }
    }
</script>

<style type="text/css">
  .align-center{
    margin:0 auto;      /* 居中 这个是必须的，，其它的属性非必须 */
    width:1000px;        /* 给个宽度 顶到浏览器的两边就看不出居中效果了 */
    background:white;     /* 背景色 */
    text-align:center;  /* 文字等内容居中 */
  }
</style>
